<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
	<head> 
    <meta charset="UTF-8">
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <link rel="stylesheet" href="${ctxStatic}/css/common_erp.css">
    <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
    <script>
    
   $(document).ready(function(){

	   if ($("#id").val()!=null&&$("#id").val()!=0) {
			$("#brandCn").attr("disabled","disabled");
			}
	   $("#backBtn").click(function(){
           $("#showHtml").removeClass("showHtml");
           $("#confirmPage").css("display","none");
           $("#editPage").css("display","block");
           $("#showHtml").find("input").removeAttr("disabled");
           $("#showHtml").find("textarea").removeAttr("disabled");
           return false;
       });
	}); 
    
   
   //保存方法
   var checkForm={
           t:null,
           check:function(t){
               $(t).attr("disabled",true);
               this.t=t;	
               $("#inputForm").validate({
                  
                   // 重名验证
                   rules: {
                	brandCn: {remote: "${ctx}/customer/brand/checkName "},
                   },
                   messages: {
                    //数据值以存在
                    brandCn: {remote: '<spring:message code="brand_name_exits"/>'},
                   },
                   fail: function(element,e) {  
                        $(saveForm.t).attr("disabled",false);
                   },
                   
                   submitHandler: function(form) {
  	                 $("#showHtml").addClass("showHtml");
  	                 $("#confirmPage").css("display","block");
  	                 $("#editPage").css("display","none");
  	                 $(checkForm.t).attr("disabled",false);
  	              $("#showHtml").find("input").attr("disabled","disabled");
  	              $("#showHtml").find("select").attr("disabled","disabled");
  	              $("#showHtml").find("textarea").attr("disabled","disabled");
                   }
               });
               
               // 提交表单
               $("#inputForm").submit(); 
           }
   }
   
   
   
   var saveForm={
   s:null,
   t:null,
   save:function(s,t){
       $(t).attr("disabled",true);
       this.s=s;
       this.t=t;
       // 格式化，去除逗号
       
       formUnFormat($("#inputForm"));
       $("#showHtml").find("input").removeAttr("disabled");
       $("#showHtml").find("textarea").removeAttr("disabled");
	   var params = $("#inputForm").serialize();
       $.post("${ctx}/customer/brand/save",params, function(result) {
      	 // 提示信息
           tipParent(result.message);
           // 返回状态
           if(result.statusCode==STATUSCODEOK){
               if(saveForm.s==1){

                // 刷新页面
                   window.parent.frames[0].searchListForm();
                   
               }else{
                   window.parent.frames[0].searchListForm();
                   closeWin(); 
               }
             }else{
                 $(saveForm.t).attr("disabled",false);
             }
       },'json');
   } 
} 
    </script> 
    </head>
	<body>  
		<!-- 创建页面head部 -->
	<div id="editPage" class="layerHeader clearfix">
	
		<c:choose>
	        <c:when test="${dict.id!=null && dict.id!=''}">
	             <!-- 修改编辑 -->
	            <p class="headerTitle"><spring:message code="dict_modifyDict"/></p>
	        </c:when>
	        <c:otherwise>
	             <!-- 新建 -->
	            <p class="headerTitle"><spring:message code="dict_createAccount"/></p>
	        </c:otherwise>
	    </c:choose>

	    <div class="headerButton clearfix">
	    <shiro:hasPermission name="customer:brand:edit">
	       <button type="button" id="confirmBtn" onclick="checkForm.check(0,this)"><spring:message code="btn_ok"/></button>
	    </shiro:hasPermission>
	       <button type="button" onclick="closeWin()"><spring:message code="btn_cancle"/></button>
	    </div>
	</div> 
	
		<!-- 确认页面head部 -->
	<div id="confirmPage" class="layerHeader clearfix" style="display:none">
		<p class="headerTitle"><spring:message code="confirmation_of_accounts"/></p>
	    <div class="headerButton clearfix">
	        <shiro:hasPermission name="finance:subject:edit">
	        <button type="button" id="saveBtn" onclick="saveForm.save(0,this)"><spring:message code="common_save"/></button>
 			</shiro:hasPermission>
	        <button type="button" onclick="closeWin()"><spring:message code="btn_cancle"/></button>
	    </div>
	</div>
<form id="inputForm" method="post">
<!-- 创建编辑头部 -->

<!-- 入力框 -->
  <input type="hidden" id="id" name="id" value="${brand.id}"/>
<div id="showHtml" class="tabBoxSm" >
	<div class="smList">
	        <div class="items clearfix" >
	        	<div class="col-50 clearfix haveToBox" >
	        		  <!--  品牌名称： -->
	                <p class="tit"><spring:message code="brand_name" /></p>
					<input  id="brandCn" name="brandCn" value="${brandList[0].brandCn}" onblur="changeItemCode()" data-rule-required="true" data-msg-required="<spring:message code="brand_name_corrlet"/>">
					<p class="haveTo">*</p>
	            </div>            
	        </div>

	        <div class="items clearfix">
	        	<div class="col-50 clearfix haveToBox">
	        		 <!--  品牌英文名称-->
	                <p class="tit" ><spring:message code="brand_english_name" /></p>
	                <input id="brandEn"  name="brandEn" value="${brandList[0].brandEn}" data-rule-required="true" data-msg-required="<spring:message code="brand_eng_name_corrlet"/>">
	                <p class="haveTo">*</p>
	            </div>
	        </div>

	
	        <div class="items clearfix">
	        	<div class="col-50 clearfix">
	        		<!--状态-->
					<p class="tit"><spring:message code="dict_state" /></p>
					<div class="labelBox">
						<!--启用-->
						<label> <input type="radio" name="enableFlag"
							checked='checked' value="1"
							<c:if test="${brand.enableFlag eq 1}">checked="checked"</c:if>
							class="rast" /> <spring:message code="dict_enable" /> 
						</label>
						<!--停用-->
						<label><input type="radio" name="enableFlag" value="0"
							<c:if test="${brand.enableFlag eq 0}">checked="checked"</c:if>
							class="rast" /> <spring:message code="dict_disable" /> 
						</label>
					</div>
	            </div>
	        </div>
	        <div class="items clearfix">
		       <!-- 描述 -->
               <p class="tit"><spring:message code="brand_remarks"/>(0/100)</span></p>
               <textarea style="width:400px;height: 140px" name="remarks"  value="${brandList[0].remarks}">${brandList[0].remarks}</textarea>
		    </div> 
	        
	</div>

</div>

</form>
<script>
</script>
</body>
</html>